<!--#include file="inc/conn.asp" -->
<!--#include file="inc/Function.asp" -->


<%




CheckAdmin()
Itemtype=request("Itemtype")
Select Case (Itemtype)
Case 1 
  dbname="user_storage"
  dbname2="角色仓库"
Case 2 
  dbname="user_bag"
  dbname2="角色背包"
Case 3
  dbname="user_suit"
  dbname2="角色自身"
Case 4
  dbname="USER_STORE"
  dbname2="角色商店"
Case 5
  dbname="USER_POSTBOX"
  dbname2="角色邮箱"

End select 
character_no=Trim(checkstr(request("character_no")))

If request("Action") = "Del" Then
Windex = Trim(checkstr(request("Windex")))
line_no= Trim(checkstr(request("line_no")))
abyHeader = Trim(checkstr(request("byHeader")))
	If Itemtype=5 Then 
		set rs=conn_c.execute("Delete  from "&dbname&" where Windex="&Windex&" and  post_no="&line_no&" and character_no='"&character_no&"'" )
	Else
	set rs=conn_c.execute("Delete  from "&dbname&" where Windex="&Windex&" and  line_no="&line_no&" and character_no='"&character_no&"'" )
	End If 

	response.write "{""msg"":""装备"&itemname&"删除成功!"",""status"":""yes""}"
	response.end

ElseIf request("Action") = "Update" Then

Windex = Trim(checkstr(request("Windex")))
iteminfo= Trim(request("info"))
line_no= Trim(checkstr(request("line_no")))
OldWindex= Trim(checkstr(request("OldWindex")))
OldName= request("OldName")
SerialNumber=Trim(request("dwSerialNumber"))
abyHeader = Trim(checkstr(request("byHeader")))
set rsitem=conn_i.execute("select *  from item where itemid="&Windex&"" )
If rsitem.eof Or rsitem.bof Then 
			response.write "<script language=javascript>alert('错误的装备代码!');history.back()</script>"
			response.End
Else
itemname=rsitem("itemname")
End If


If Itemtype=5 Then 
		set rs1=conn_c.execute("update "&dbname&" set  Windex="&Windex&" , [info]=0x"&iteminfo&" ,[byHeader]=0x"&abyHeader&"   where Windex="&OldWindex&"  and post_no="&line_no&" and character_no='"&character_no&"'")

	Else
		set rs1=conn_c.execute("update "&dbname&" set  Windex="&Windex&" , [info]=0x"&iteminfo&" ,[byHeader]=0x"&abyHeader&"   where Windex="&OldWindex&"  and line_no="&line_no&" and character_no='"&character_no&"'")
	End If 


'set rs_log=conn.execute("INSERT INTO adminlog (admin,datetime,ip,username,adminlog,logtype) VALUES('"&admin_user&"',getdate(),'"&ip&"','"&character_no&"','"&"修改道具"&OldWindex&"-"&OldName&"为:"&Windex&"-"&itemname&"',1)") '写日志


ElseIf request("Action") = "Copy" Then

Windex = Trim(checkstr(request("Windex")))
info= Trim(request("info"))
dwSerialNumber=Trim(request("dwSerialNumber"))
byHeader= Trim(request("byHeader"))
IName= Trim(request("IName"))

'If  session("SuperAdmin")=1 Then 
'cid=admin_character
'Else
'cid=admin_character
'End If 

post_no=createssn
set rs=server.CreateObject("adodb.recordset")
sqlstr="select * from user_postbox "
rs.open sqlstr,conn_c,1,3
Rs.AddNew
rs("character_no")=admin_character
rs("post_no")=post_no
rs("from_char_nm")="CNCTZ道具管理系统" 
rs("post_sort")=4 'gm发送为0
rs("post_title")="商品发放"
rs("body_text")="系统发放或补偿物品"
rs("state_tag")=0 '0未查看1以查看
rs("item_tag")=1  '1未取出 2已取出
rs("byHeader")=byHeader
rs("wIndex")=wIndex '装备代码
rs("dwSerialNumber")="00000000000000000000000000000000" '未知
rs("info")=info '亮金属性
rs("dil_tag")=0	'未知
rs("include_dil")=0	'未知
rs("ipt_time")=Now() '发送时间
rs("expire_time")=Now()+15 '过期日期
rs("reg_bindate")="00000000"	'未知
rs("exp_bindate")="00000000"	'未知
rs("byRebirthFlag")="1"	'未知

rs.update
rs.close

'set rs_log=conn.execute("INSERT INTO adminlog (admin,datetime,ip,username,adminlog,logtype) VALUES('"&admin_user&"',getdate(),'"&ip&"','"&cid&"','"&"复制装备"&Windex&"-"&IName&"',1)") '写日志
set rs=nothing
	conn.close
	set conn=Nothing
	response.write "{""msg"":""装备"&itemname&"复制到"&admin_character&"成功!"",""status"":""yes""}"
	response.end

End If


Set Rs = Server.CreateObject("adodb.recordset")

 sql="select *  from "&dbname&" where character_no='"&character_no&"'"


Call  head("装备查看")

%>

                    <div class="layui-card">
                        <div class="layui-card-body layui-table-body layui-table-main">
                            <table class="layui-table layui-form">
                                <thead>
                                  <tr>
								 <!-- <th style="min-width: 15px;    max-width: 20px;"> <input type="checkbox" name="like1[read]" lay-skin="primary"></th>-->
                                    <th height="30" style="min-width: 40px;    max-width: 45px;"><%=dbname2%>装备</th>
                                    <th>数量</th>
                                    <th>属性(windex/info/byheader)</th>
                                    <th>操作</th>
									</tr>
                                </thead>
                                <tbody>
	<%
rs.open sql,conn_c,1,1
if rs.eof and rs.bof then 
response.write "<TR><TD height=30 colspan=""5"">没有数据..</TD></TR>" 
else
do while not rs.eof

%>        <form name="form" method="post" action="?Action=Update">

     
									<tr>
								  
                                    <td><%
		  SET RS3 = conn_i.Execute("select itemname,itemid from Item where itemid="&rs("Windex")&"")
		   If rs3.eof Or rs3.bof Then 
		  itemname="未知"
		  Else
		  itemname=rs3(0)
		  End If 
		   rs3.close
		  Set rs3=Nothing

If Itemtype<>5 Then 
line_no=rs("line_no")
Else
line_no=rs("post_no")
End If 

byHeader=rs("byHeader")
Hexinfo=ShowHex(rs("info"))


		  %>
		  
		   <%=itemname%></td>
									  <td><%if isChkInteger(Hexnumber(Hexinfo)) then response.write left(Hexnumber(Hexinfo),5) else response.write "1"%></td>
                                    <td> 


								<input name="Windex" type="text" id="Windex" value="<%=rs("Windex")%>" size="7" maxlength="7">
								<input name="info" type="text" id="info" value="<%=Hexinfo%>" size="66" maxlength="86">

									<input name="byHeader" type="text" id="byHeader" value="<%=byHeader%>" size="3" maxlength="3"><br><%=itemoption(Hexinfo,byHeader)%></td>
                                    <td>
										 <button class="layui-btn layui-btn-danger layui-btn-sm"  lay-submit="" lay-filter="update" onclick="member_del(this,'<%=rs("Windex")%>','<%=rs("character_no")%>','<%=line_no%>','<%=Itemtype%>','<%=ItemName%>')">删</button>
										 <button class="layui-btn layui-btn-warm layui-btn-sm"  lay-submit="" lay-filter="update" onclick="member_Copy(this,'<%=itemname%>','<%=rs("Windex")%>','<%=byHeader%>','<%=ShowHex(rs("info"))%>','<%=character_no%>','<%=Itemtype%>')" >复</button>
										<input name="line_no" type="hidden" id="line_no" value="<%=line_no%>">
										<input name="character_no" type="hidden" id="character_no" value="<%=rs("character_no")%>">
										<input name="Itemtype" type="hidden" id="Itemtype" value="<%=Itemtype%>">
										<input name="OldWindex" type="hidden" id="OldWindex" value="<%=rs("Windex")%>">
										<input name="OldName" type="hidden" id="OldName" value="<%=itemname%>">
										  &nbsp;<button class="layui-btn layui-btn-normal layui-btn-sm"  lay-submit="" lay-filter="update">改</button>
										</td>

			
		   </TD>

                                  </tr></form>
                                                                
<%
rs.movenext
loop
end if
		 %>
                                </tbody>
                            </table>
					</div>
					
				<div class="layui-col-md12">
						<blockquote class="layui-elem-quote layui-quote-nm">炽天SRO管理系统 Request Time <%=Int(FormatNumber((Timer() - TimerStart) * 1000, 3))%> ms</blockquote></div>
				</div>
        </div> 

<script>
     /*用户-删除*/
      function member_del(obj,Windex,character_no,line_no,Itemtype,ItemName){
          //layer.confirm('确认要删除吗？',function(index){
              //发异步删除数据


				//layer.msg(id);
				$.ajax({
				url: "user_item.asp?Action=Del" ,
				data: {'Windex':Windex,'character_no':character_no,'line_no':line_no,'Itemtype':Itemtype,'ItemName':ItemName} ,
				type: "get" ,
				dataType:'json',
				success:function(data){
			   if(data.status=='yes'){
              $(obj).parents("tr").remove();
				 layer.msg(data.msg, {icon: 1,time:1000});
				//location.reload();
				}else{
              layer.msg('删除失败!',{icon:5,time:1000});
				}
				}
				})
        //  }); //确认
      }

		function member_Copy(obj,itemname,Windex,byHeader,info,character_no,Itemtype){
          //layer.confirm('确认要删除吗？',function(index){
              //发异步删除数据
				$.ajax({
				url: "user_item.asp?Action=Copy" ,
				data: {'itemname':itemname,'Windex':Windex,'byHeader':byHeader,'info':info,'character_no':character_no,'Itemtype':Itemtype} ,
				type: "get" ,
				dataType:'json',
				success:function(data){
			   if(data.status=='yes'){
				   				 layer.msg(data.msg, {icon: 1,time:1000});

				//location.reload();
				}else{
              layer.msg('复制失败!',{icon:5,time:1000});
				}
				}
				})
      }

	  //监听提交
layui.use('form', function(){
  var form = layui.form;
    form.on('submit(update1)', function(data){
    // layer.msg(JSON.stringify(data.field));//弹出json格式所有表单的值
	//return false;
    $.ajax({
      type:"get",
       url:"user_item.asp?Action=Update",
	  data: data.field,
      dataType:"json",
      success:function(data){
        if(data.status=='yes'){
		   layer.msg(data.msg, {icon: 1,time:5000});
          //var url = "{:U('device/getinfo')}"; //成功跳转的url
          //setTimeout(window.location.href=url,2000);
        }else{
		   layer.msg(data.msg, {icon: 2,time:5000});
        }
      },
    });
	return false;
  });
});

        </script>
			<%Call  footer%>
